/*
HashRouter:有#号
BrowserRouter:没有#号
Route：设置路由与组件关联
Switch:只要匹配到一个地址不往下匹配，相当于for循环里面的break
Link:跳转页面，相当于vue里面的router-link
exact :完全匹配路由
Redirect:路由重定向
*/

import React,{lazy,Suspense} from 'react';
import {BrowserRouter as Router, Route, Switch ,Redirect} from 'react-router-dom';

const index=lazy(()=>import('./pages/index'));
const indexMob=lazy(()=>import('./pages/mobile/index'));
const about=lazy(()=>import('./pages/about'));
const aboutMob=lazy(()=>import('./pages/mobile/about'));
const benefit=lazy(()=>import('./pages/benefit'));
const benefitMob=lazy(()=>import('./pages/mobile/benefit'));
const job=lazy(()=>import('./pages/job'));
const jobMob=lazy(()=>import('./pages/mobile/job'));
const position=lazy(()=>import('./pages/job/position'));
const positionMob=lazy(()=>import('./pages/mobile/job/position'));
const union=lazy(()=>import('./pages/union'));
const unionMob=lazy(()=>import('./pages/mobile/union'));
const nj=lazy(()=>import('./pages/nj'));
const njMob=lazy(()=>import('./pages/mobile/nj'));
const senc=lazy(()=>import('./pages/senc'));
const sencMob=lazy(()=>import('./pages/mobile/senc'));
const group=lazy(()=>import('./pages/growingup'));
const groupMob=lazy(()=>import('./pages/mobile/growingup'));
const bigbus=lazy(()=>import ('./pages/bigbus'));
const bigbusMob=lazy(()=>import ('./pages/mobile/bigbus'));
const from=lazy(()=>import('./pages/from'));
const fromMob=lazy(()=>import ('./pages/mobile/from'));


class RouterComponent extends React.Component{
  render(){
    return(
      <React.Fragment>
        <Router>
          <React.Fragment>
              <Suspense fallback={<React.Fragment ></React.Fragment>}>
                  <Switch>
                      <Route exact path={window.base.config.path} component={index}></Route>
                      <Route exact path={window.base.config.path+'mob'} component={indexMob}></Route>
                      <Route path={window.base.config.path+'index'} component={index}></Route>
                      <Route path={window.base.config.path+'mob/index'} component={indexMob}></Route>
                      <Route path={window.base.config.path+'about'} component={about} ></Route>
                      <Route path={window.base.config.path+'mob/about'} component={aboutMob} ></Route>
                      <Route path={window.base.config.path+'benefit'} component={benefit} ></Route>
                      <Route path={window.base.config.path+'mob/benefit'} component={benefitMob} ></Route>
                      <Route path={window.base.config.path+'job'} component={job}></Route>
                      <Route path={window.base.config.path+'mob/job'} component={jobMob}></Route>
                      <Route path={window.base.config.path+'position'} component={position}></Route>
                      <Route path={window.base.config.path+'mob/position'} component={positionMob}></Route>
                      <Route path={window.base.config.path+'union'} component={union}></Route>
                      <Route path={window.base.config.path+'mob/union'} component={unionMob}></Route>
                      <Route path={window.base.config.path+'nj'} component={nj}></Route>
                      <Route path={window.base.config.path+'mob/nj'} component={njMob}></Route>
                      <Route path={window.base.config.path+'senc'} component={senc}></Route>
                      <Route path={window.base.config.path+'mob/senc'} component={sencMob}></Route>
                      <Route path={window.base.config.path+'growingup'} component={group}></Route>
                      <Route path={window.base.config.path+'mob/growingup'} component={groupMob}></Route>
                      <Route path={window.base.config.path+'bigbus'} component={bigbus}></Route>
                      <Route path={window.base.config.path+'mob/bigbus'} component={bigbusMob}></Route>
                      <Route path={window.base.config.path+'from'} component={from}></Route>
                      <Route path={window.base.config.path+'mob/from'} component={fromMob}></Route>

                      {/*<AuthRoute path={window.base.config.path+'user'} component={User}></AuthRoute>*/}
                      <Redirect to={window.base.config.path} ></Redirect>

                  </Switch>
              </Suspense>
          </React.Fragment>
        </Router>
      </React.Fragment>
    )
  }
}

export default RouterComponent;
